/**
 * 
 */
package org.tinygroup.bizframe.basedao;

import org.tinygroup.tinysqldsl.KeyGenerator;
import org.tinygroup.tinysqldsl.base.InsertContext;

/**
 * @author Paul
 *
 */
public class MultiSeqenceKeyGenerator implements KeyGenerator {

	private MultiSequenceProcessor processor;
	
	/* (non-Javadoc)
	 * @see org.tinygroup.tinysqldsl.KeyGenerator#generate(org.tinygroup.tinysqldsl.base.InsertContext)
	 */
	@SuppressWarnings("unchecked")
	public Long generate(InsertContext insertContext) {
        
		try {
			Long id= processor.nextKey(insertContext.getTableName());
			System.out.println(id);
			return id;
		} catch (Exception e) {
			throw new RuntimeException("获取主键错误",e);
		}
	}

	public MultiSequenceProcessor getProcessor() {
		return processor;
	}

	public void setProcessor(MultiSequenceProcessor processor) {
		this.processor = processor;
	}

}
